package com.jiyun.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiyun.orders.pojo.Orders;
import com.jiyun.result.Result;
import com.jiyun.service.StatisticsService;
import com.jiyun.statistics.ChartDataVo;
import com.jiyun.statistics.Count;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zqtao
 */
@Tag(name = "统计API接口管理")
@RestController
@RequestMapping("/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    @Operation(summary = "开启定时任务")
    @GetMapping("/startXxlJob/{pageNum}/{pageSize}")
    public Result<Long> startXxlJob(@PathVariable Integer pageNum, @PathVariable Integer pageSize){
        return Result.ok(statisticsService.startXxlJob(pageNum, pageSize));
    }

    @Operation(summary = "获取订单数据")
    @GetMapping("/getData/{pageNum}/{pageSize}")
    public Result<Page<Orders>> getData(@PathVariable Integer pageNum, @PathVariable Integer pageSize){
        return Result.ok(statisticsService.getData(pageNum, pageSize));
    }

    @Operation(summary = "获取统计数据")
    @GetMapping("/count")
    public Result<Count> count(){
        return Result.ok(statisticsService.countToday());
    }


    @Operation(summary = "获取本月统计数据")
    @GetMapping("/countMouth")
    public Result<Count> countMouth(){
        return Result.ok(statisticsService.countMouth());
    }

    @Operation(summary = "获取图表数据")
    @GetMapping("/getChartData")
    public Result<ChartDataVo> getChartData(){
        return Result.ok(statisticsService.getChartData());
    }



}
